export const HolidayOptions = [
  {
    label: "事假",
    value: "Personal",
  },
  {
    label: "年假",
    value: "Annual",
  },
  {
    label: "病假",
    value: "Sick",
  },
  {
    label: "其它（婚假、育儿假、丧假）",
    value: "Other",
  },
];

export const businessStatusOptions = [
  { label: "草稿", value: "DRAFT" },
  { label: "在办", value: "UNDO" },
  { label: "办结", value: "DONE" },
  { label: "审批中", value: "AUDIT" },
  { label: "已审批", value: "AUDITED" },
  { label: "已归档", value: "FINISH" },
  { label: "已撤回", value: "REBACK" },
];

export const formData = {
  businessId: "",
  businessType: "",
  auditMemo: "",
  createBy: "",
  deptName: "",
  createTime: "",
  telephone: "",
  holidayType: "",
  holidayTypeName: "",
  startTime: "",
  endTime: "",
  content: "",
  auditItems: [],
  businessStatus: "",
  auditorIds: "",
  auditorNames: "",
  busiAttachIds: "", //文件ids
  busiAttachs: [],
};

export const baseFileds = (type, startTime, endTime) => {
  return [
    {
      key: "createBy",
      filedType: "Input",
      label: "创建人",
      span: 12,
      disabled: true,
    },
    {
      key: "deptName",
      filedType: "Input",
      label: "创建部门",
      span: 12,
      disabled: true,
    },
    {
      key: "createTime",
      filedType: "Input",
      label: "创建时间",
      span: 12,
      disabled: true,
      isTimeFilter: true,
    },
    {
      key: "telephone",
      filedType: "Input",
      label: "联系电话",
      span: 12,
      disabled: type !== "add",
      props: {
        placeholder: "请输入联系电话",
        type: "number",
      },
    },
    {
      key: "holidayType",
      showKey: "holidayTypeName",
      filedType: "Select",
      label: "请假类型",
      span: 24,
      disabled: type !== "add",
      props: {
        placeholder: "请选择",
        options: HolidayOptions,
        rules: [
          { required: true, message: "请选择请假类型", trigger: "change" },
        ],
      },
    },
    {
      key: "startTime",
      filedType: "DateTimePicker",
      label: "请假开始时间",
      span: 12,
      disabled: type !== "add",
      isTimeFilter: true,
      props: {
        placeholder: "请选择",
        type: "datetime",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        pickerOptions: {
          disabledDate: (time) => {
            return endTime ? time.getTime() > new Date(endTime).getTime() : "";
          },
        },
        rules: [
          {
            required: true,
            message: "请选择请假开始时间",
            trigger: "change",
          },
        ],
      },
    },
    {
      key: "endTime",
      filedType: "DateTimePicker",
      label: "请假结束时间",
      span: 12,
      disabled: type !== "add",
      isTimeFilter: true,
      props: {
        placeholder: "请选择",
        type: "datetime",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        pickerOptions: {
          disabledDate: (time) => {
            return startTime
              ? time.getTime() < new Date(startTime).getTime()
              : "";
          },
        },
        rules: [
          {
            required: true,
            message: "请选择请假结束时间",
            trigger: "change",
          },
        ],
      },
    },
    {
      key: "content",
      filedType: "Input",
      label: "请假原因",
      span: 24,
      disabled: type !== "add",
      props: {
        placeholder: "请假原因",
        type: "textarea",
        rules: [{ required: true, message: "请填写请假原因", trigger: "blur" }],
      },
    },
  ];
};
